package com.ycd.Servlet;

import com.ycd.Service.LanMuEntityService;
import com.ycd.Service.XinWenEntityService;
import com.ycd.Service.impl.LanMuEntityServiceImpl;
import com.ycd.Service.impl.XinWenEntityServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description 删除用户
 * @Author ycd
 * @Date : 2022/3/17 16:53
 * @Version : 1.0
 */
@WebServlet("/delNews")
public class DelXinWenServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //规范字符集
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        String id=req.getParameter("id");

        XinWenEntityService x =new XinWenEntityServiceImpl();
        if(id!=null){
            x.delXinWen(Integer.parseInt(id));
            resp.sendRedirect("NewsManagement.html");

        }

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
